package _1ChapterOne._5IntroduceExplainingVariable;

import _1ChapterOne._4ReplaceTempWithQuery.BaseClass;

public class Test1 extends BaseClass {
    public double getPriceOld() {
        return _itemPrice * _quantity - Math.max(0, _quantity - 500) * _quantity * 0.05
                + Math.min(100.0, _quantity * _itemPrice * 0.01);
    }

    public double getPriceNew() {
        int basePrice = _itemPrice * _quantity;
        double quantityDiscount = Math.max(0, _quantity - 500) * _quantity * 0.05;
        double shipping = Math.min(100.0, _quantity * _itemPrice * 0.01);
        return basePrice - quantityDiscount + shipping;
    }
}
